package com.oocl.euc.audit;

import com.oocl.euc.authentication.core.UserInfo;
import com.oocl.euc.common.utils.UserContextHolder;
import com.oocl.euc.core.maintenance.model.Users;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component("auditorAware")
public class AuditorAwareImpl implements AuditorAware<Users> {

    @Override
    public Optional<Users> getCurrentAuditor() {
        UserInfo userInfo = UserContextHolder.getUserContext().getUserInfo();
        Users users = new Users();
        users.setStaffId(userInfo.getId());
        users.setDomainId(userInfo.getDomainId());
        return Optional.of(users);
    }
}
